package com.thzy.bbs.thread;

import android.os.Handler;

import com.thzy.bbs.callBacks.LoginCallBack;
import com.thzy.bbs.common.AddressConfig;
import com.thzy.bbs.common.Constants;
import com.thzy.bbs.common.EncodeUtils;
import com.thzy.bbs.common.HttpRequestUtils;

import org.xutils.http.HttpMethod;

import java.util.HashMap;
import java.util.Map;

/**
 * 用户登录线程
 *
 * @author Lirui
 * @date 2017/1/4 14:05
 */

public class LoginThread implements Runnable {
    private String userName;
    private String passWord;
    private Handler handler;
    private String regId;

    public LoginThread(String userName, String passWord, Handler handler, String regId) {
        this.userName = userName;
        this.passWord = passWord;
        this.handler = handler;
        this.regId = regId;
    }

    @Override
    public void run() {
        Map<String, Object> params = new HashMap<>(3);
        params.put("userName", userName.trim());
        params.put("pwd", EncodeUtils.encodeMD5(passWord.trim()));
        params.put("deviceId", regId);
        HttpRequestUtils.sendAsynchronous(HttpMethod.POST, AddressConfig.ConfigAddress.LOGIN_INDEX, null, params, 6000, false, new LoginCallBack(handler));
    }

}
